package qs.openxt.libs.remoting;

import android.content.Context;

import qs.openxt.libs.progress.Wait;

public class ConvertAudioRecord {
	public static final String MP3 = "MP3";
	protected Context context = null;

	protected OnActionListener listener = null;

	private ConvertBusinessTask task = null;

	public ConvertAudioRecord(Context context, OnActionListener l) {
		this.context = context;
		this.listener = l;
	}

	public void doConvert(String path) {
		Wait.sharedInstance().start(context, "正在转码...，请稍候");
		try{
			task = new ConvertBusinessTask(this);
			task.execute(ConvertAudioRecord.MP3, path);
		} catch (Exception e) {
			Wait.sharedInstance().stop();
		}
	}

	public void doSuccess(String reVal) {
		Wait.sharedInstance().stop();

		if (listener != null) {
			listener.onActionCompleted(reVal);
		}
	}

	public abstract interface OnActionListener {
		public abstract void onActionCompleted(String reVal);
	}
}
